package student.object.thread.wait;

import student.object.thread.SleepThread;
import student.object.thread.WaitThread;

public class Test {

    public static void main(String[] args) {

        WaitService mWaitService = new WaitService();

        Thread sleepThread = new Thread(new SleepThread(mWaitService));
        Thread waitThread = new Thread(new WaitThread(mWaitService));
        waitThread.start();
        sleepThread.start();


        /*
           1.waitThread先执行wait方法，然后打印一句话进入等待状态并释放synchronized锁，锁住的this。
           2.sleepThread然后打印开始睡眠，并睡眠3秒钟，然后唤醒所有等待线程。waitThread开始被唤醒。
           3.waitThread开始工作，继续执行，打印等待结束。
         */
    }
}